package commons.groovy;

import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;

import commons.BizException;

public class GroovyInstance {
	
	
	public static void loadObject(GroovyClassLoader cloader, String clazzResource) {
//		Class<?> clazz = cloader.parseClass(clazzResource);
		cloader.parseClass(clazzResource);
	}
	
	public static GroovyObject parseObject(GroovyClassLoader cloader, String clazzResource) {
		
//		cloader.addURL(url);
		
		Class<?> clazz = cloader.parseClass(clazzResource);
		try {
			return (GroovyObject)clazz.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
			throw new BizException(e);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
			throw new BizException(e);
		}
	}
	
	
}
